<template>
  <div id="sign" v-if="show">
    <div class="bg" @click="clear" v-if="show"></div>
    <div class="modal">
      <div class="modal-top">
        <div class="modal-title">举报（举报发布的内容）</div>
        <div class="modal-clear" @click="clear">
          <img src="../assets/imgs/shanchu.png" alt="" />
        </div>
      </div>
      <div class="modal-btns">
        <div
          class="modal-single"
          v-for="(item, index) in modal"
          :key="index"
          :class="item.show ? 'selected' : ''"
          @click="selMoney(item.id, item.name)"
        >
          <div class="gift-text">{{ item.name }}</div>
        </div>
      </div>
      <div class="sign-btns">
        <div class="pay" @click="confirm()">确定</div>
        <div class="clear" @click="clear">取消</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props:{
    reportId:{
      type:Number,
    }
  },
  data() {
    return {
      modal: [
        { name: "辱骂攻击", id: 0 },
        { name: "政治敏感", id: 1 },
        { name: "引战", id: 2 },
        { name: "垃圾广告", id: 3 },
        { name: "诈骗信息", id: 4 },
        { name: "其他", id: 5 },
        { name: "色情低俗", id: 6 },
        { name: "违法违规", id: 7 },
        { name: "血腥暴力", id: 8 },
      ],
      show: false,
      id: -1,
      loading: true,
      name: "",
      articleId:0,
    };
  },
  watch:{
    reportId:{
      handler(newVal,oldVal){
        this.articleId = newVal;
      }
    }
  },
  created() {
    this.initList();
  },
  mounted() {
    this.getRem(1920, 100);
  },
  computed: {},

  methods: {
    async initList() {
      for (let i of this.modal.keys()) {
        this.$set(this.modal[i], "show", false);
      }
    },
    //选择举报内容
    selMoney(id, name) {
      this.id = id;
      this.name = name;
      for (let i of this.modal.keys()) {
        this.modal[i].show = false;
      }
      let res = [...this.modal].find((item) => id == item.id);
      res.show = true;
    },
    clear() {
      this.show = !this.show;
      this.isCode = true;
    },
    confirm() {
      if (this.id === -1 || this.name == "") {
        this.$message.warning("请选择举报理由");
        return false;
      }
      this.$post(
        `/laiwen/report/frontend/save?beReportedId=${this.articleId}&reason=${this.name}`
      ).then((res) => {
        console.log(res);
        if (res.msg === "success") {
          this.$message.success("举报成功");
          this.clear()
        }
      });
    },
  },
};
</script>

<style scoped>
#sign {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  position: fixed;
  justify-content: center;
  left: 0;
  top: 0;
}
img {
  width: 100%;
  height: 100%;
  display: block;
  flex-shrink: 0;
}
.bg {
  width: 100%;
  height: 100%;
  opacity: 0.25;
  background: black;
  position: absolute;
  /* z-index: 2; */
}
.modal {
  width: 5rem;
  height: 3.64rem;
  display: flex;
  align-items: center;
  position: relative;
  flex-direction: column;
  z-index: 9999;
  background: white;
  border-radius: 0.05rem;
}
.modal .modal-top {
  width: 100%;
  height: 0.64rem;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding-left: 0.32rem;
  position: relative;
  border-bottom: 0.01rem solid #f5f5f5;
}
.modal .modal-top .modal-title {
  height: 0.2rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.2rem;
  color: rgba(40, 40, 40, 1);
  opacity: 1;
}
.modal .modal-top .modal-clear {
  width: 0.11rem;
  height: 0.11rem;
  cursor: pointer;
  position: absolute;
  right: 0.32rem;
}
.modal-btns {
  width: 3.76rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 0.24rem;
}
.modal-btns::after {
  content: "";
  width: 0.88rem;
}
.modal .modal-single {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin-bottom: 0.18rem;
  width: 1.12rem;
  height: 0.38rem;
  background: #f5f5f5;
  opacity: 1;
  cursor: pointer;
  border-radius: 0.05rem;
  border: 0.01rem solid transparent;
  background: #eeeeee;
  color: #282828;
}
image {
  width: 100%;
  display: block;
  height: 100%;
}
.modal-text {
  width: 0.42rem;
  height: 0.2rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.2rem;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
}
.code {
  margin-top: -0.42rem;
}
.codeCtn {
  width: 100%;
  height: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-btn {
  width: 0.88rem;
  height: 0.78rem;
  background: rgba(238, 238, 238, 1);
  opacity: 1;
  border-radius: 0.05rem;
  margin-top: 0.08rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}
.gift-icon {
  font-size: 0.16rem;
}
.modal-btn .gift-icon {
  width: 0.31rem;
  height: 0.31rem;
  margin-top: 0.13rem;
  font-size: 0.16rem;
}
.gift-text {
  height: 0.2rem;
  font-weight: 400;
  line-height: 0.2rem;
  opacity: 1;
  font-size: 0.15rem;
  font-family: PingFang SC;
  color: rgba(9, 9, 9, 1);
}
.sign-btns {
  width: 100%;
  display: flex;
  position: absolute;
  bottom: 0;
  height: 0.84rem;
  align-items: center;
  border-top: 0.01rem solid #f5f5f5;
  justify-content: center;
}
.pay {
  width: 1.22rem;
  height: 0.38rem;
  background: rgba(255, 189, 61, 1);
  opacity: 1;
  border-radius: 0.05rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.38rem;
  cursor: pointer;
  text-align: center;
  color: rgba(255, 255, 255, 1);
  opacity: 1;
  outline: none;
  margin-right: 0.2rem;
}
.clear {
  width: 1.22rem;
  height: 0.38rem;
  background: white;
  opacity: 1;
  border-radius: 0.05rem;
  cursor: pointer;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.38rem;
  border: 0.01rem solid rgba(153, 153, 153, 1);
  text-align: center;
  color: #282828;
  opacity: 1;
}
.clear-btn {
  width: 0.24rem;
  height: 0.24rem;
  border-radius: 50%;
  opacity: 1;
  position: absolute;
  right: -0.24rem;
  top: 0.18rem;
  cursor: pointer;
}
/* 选中后的样式 */
.selected {
  background: #dddddd !important;
}
</style>
